package com.sy.pet.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sy.pet.commom.ResultBean;
import com.sy.pet.dto.PetQueryDTO;
import com.sy.pet.entity.PetTag;
import com.sy.pet.entity.PetType;
import com.sy.pet.service.PetInfoService;
import com.sy.pet.service.PetTagService;
import com.sy.pet.service.PetTypeService;
import com.sy.pet.vo.PetVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: liangSY
 * @Date: 2024/9/15
 * @ClassName: CommonController
 * @Description: CommonController描述
 */
@RequestMapping("/common")
@RestController
public class CommonController {

    @Autowired
    PetTagService petTagService;
    @Autowired
    PetTypeService petTypeService;
    @Autowired
    PetInfoService petInfoService;

    @GetMapping("/pet/tag/list")
    private ResultBean<List<PetTag>> getTags(){
        List<PetTag> all = petTagService.getAll();
        return ResultBean.success(all);
    }

    @GetMapping("/pet/type/list")
    private ResultBean<List<PetType>> getPetTypes(){
        List<PetType> all = petTypeService.getAll();
        return ResultBean.success(all);
    }

    @PostMapping("/pet/list")
    private ResultBean<IPage<PetVO>> getPetList(@RequestBody PetQueryDTO dto){
        IPage<PetVO> all = petInfoService.getDataByPage(dto);
        return ResultBean.success(all);
    }

}
